<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>条件渲染指令</title>

</head>
<body>
<div id="app">
    <template v-if="type === 'name'">
        <label>用户名：</label>
        <input placeholder="输入用户名">
        <!-- key可以让输入框中的内容不被复用 -->
    </template>
    <template v-else>
        <label>邮箱：</label>
        <input placeholder="输入邮箱">
    </template>
    <button @click="handleToggleClick">切换输入类型</button>
    <script src="../../vue.min.js"></script>
    <script>
        var app = new Vue({
            el: "#app",
            data: {
                type: 'name'
            },
            methods: {
                handleToggleClick: function () {
                    this.type = this.type === 'name' ? 'mail' : 'name';
                }
            }
        })
    </script>
</div>
</body>
</html>